package com.hello.booksale.util;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@Component
public class RedisUtil {
    @Resource
    private RedisTemplate<String, Integer> redisTemplate;

    public void writeKeyValueToRedis(String key, int value) {
        redisTemplate.opsForValue().set(key, value, 10, TimeUnit.MINUTES);
    }
    public Integer getKeyValueFromRedis(String key) {
        return redisTemplate.opsForValue().get(key);
    }
}
